<!-- 页面属性配置 -->
<template>
  <div class="control-item">
    <div class="control-header">页面设置</div>
    <div class="control-body">
      <div class="control-section">
        <div class="control-item">
          <div class="control-title">页面名称</div>
          <div class="control-content">
            <div class="input-section">
              <a-input placeholder="页面名称" v-model="params.page_name" />
            </div>
          </div>
        </div>
        <!-- 背景控制组件 -->
        <div class="bg-controls">
          <span>背景填充</span>
          <span class="reset" @click="resetBg">重置</span>
        </div>
        <bgControl
          :backgroudData.sync="params.pageCss"
          :showHeader="false"
        ></bgControl>
      </div>
    </div>
  </div>
</template>

<script>
import spaceControl from "@/components/DiyNew/diy/baseControl/spaceControl/index.vue";
import bgControl from "@/components/DiyNew/diy/baseControl/bgControl/index.vue";
import { pageInitData } from "@/components/DiyNew/diy/dataConfig/pageConfig.js";

export default {
  name: "pageHeader",
  components: {
    spaceControl,
    bgControl,
  },
  props: {
    params: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {
      showNumSet: false,
      bgTab: {},
    };
  },
  watch: {},
  computed: {},
  methods: {
    // 重置背景
    resetBg() {
      let data = Object.assign({}, pageInitData);
      let obj = {
        margin: 0,
        padding: data.padding,
        vSpave: data.vSpave, // 垂直间距
        hSpace: data.hSpace, // 水平间距
        borderRadius: data.borderRadius, // 圆角设置
        borderRaNum: data.borderRaNum,
        backgroundColor: "",
        backgroundImage: "",
        bgImg: "", // 该字段为替换字段
        bgOpacity: 100,
        opacity: "100",
        backgroundSize: "100% 100%",
        backgroundRepeat: "no-repeat",
      };
      console.log(data);
      this.$set(this.params, "pageCss", obj);
    },
  },
};
</script>

<style lang="scss" scoped>
.control-item {
  width: 100%;
  height: 100%;
  .control-header {
    width: 100%;
    height: 48px;
    background: #ffffff;
    border-bottom: 1px solid #f0f2f5;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 24px;
    font-size: 14px;
    color: #000000;
    font-weight: 600;
  }
  .control-body {
    width: 100%;
    .control-section {
      width: 228px;
      margin: 0 auto;
      .control-item {
        width: 100%;
        .control-title {
          font-size: 12px;
          color: #000000;
          padding: 24px 0 12px 0;
          text-align: left;
        }
        .control-content {
          width: 100%;
          .input-section {
            width: 100%;
            height: 40px;
            background: #f6f7f9;
            border-radius: 4px;
            .ant-input {
              border: 0 none;
              height: 100%;
              background-color: #f6f7f9;
            }
          }
        }
      }
      .border-set {
        .flex-between {
          display: flex;
          justify-content: space-between;
          .reset {
            color: #8c8c8c;
            cursor: pointer;
            user-select: none;
          }
        }
        .control-body {
          width: 100%;
          height: 40px;
          background: #f6f7f9;
          border-radius: 4px;
          display: flex;
          align-items: center;
          padding-left: 14px;
          .iconfont {
            font-size: 20px;
          }
          .slider {
            margin: 0 16px;
            width: 100px;
            ::v-deep .ant-slider-track {
              background-color: #1890fc;
            }
            ::v-deep .ant-slider-rail {
              background-color: #e6e6e6;
            }
          }
          .slider-input {
            width: 30px;
            font-size: 12px;
            background-color: #f6f7f9;
            ::v-deep .ant-input-number-input {
              padding: 0;
              padding-right: 5px;
              text-align: right;
            }
          }
          span {
            font-size: 12px;
            color: #000000;
          }
          .borderNumSpan {
            width: 30px;
            display: inline-block;
            text-align: right;
            padding-right: 5px;
            border: 1px solid #f6f7f9;
          }
          ::v-deep .ant-input-number-handler-wrap {
            display: none;
          }
        }
      }
      .bgimg-opacity {
        margin-top: 8px;
        .control-body {
          width: 100%;
          height: 40px;
          background: #f6f7f9;
          border-radius: 4px;
          display: flex;
          align-items: center;
          padding-left: 14px;
          .iconfont {
            font-size: 20px;
          }
          .slider {
            margin: 0 16px;
            width: 100px;
            ::v-deep .ant-slider-track {
              background-color: #1890fc;
            }
            ::v-deep .ant-slider-rail {
              background-color: #e6e6e6;
            }
          }
          .slider-input {
            width: 30px;
            font-size: 12px;
            background-color: #f6f7f9;
            ::v-deep .ant-input-number-input {
              padding: 0;
              padding-right: 5px;
              text-align: right;
            }
          }
          span {
            font-size: 12px;
            color: #000000;
          }
          .borderNumSpan {
            width: 30px;
            display: inline-block;
            text-align: right;
            padding-right: 5px;
            border: 1px solid #f6f7f9;
          }
          ::v-deep .ant-input-number-handler-wrap {
            display: none;
          }
        }
      }
      .repeat-section {
        width: 100%;
        height: 40px;
        background: #f6f7f9;
        border-radius: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-top: 8px;
        .icon-box {
          flex: 1;
          height: 100%;
          display: flex;
          justify-content: center;
          align-items: center;
          text-align: center;
          .iconfont {
            width: 32px;
            height: 32px;
            font-size: 22px;
            cursor: pointer;
            font-weight: bold;
          }
          .iconfont:hover {
            background: rgba(0, 0, 0, 0.08);
            border-radius: 4px;
          }
          .active {
            border-radius: 4px;
            color: #1890fc;
          }
        }
      }

      .bg-controls {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-top: 24px;
        font-size: 12px;
        color: #000000;
        .reset {
          color: #8c8c8c;
          cursor: pointer;
          user-select: none;
        }
      }
    }
  }
}
</style>
